<?php defined('BASEPATH') OR exit('No direct script access allowed');?>

<!-- +++++ Blog Add +++++ -->

<div class="pink">
    <div class="container">
        <div class="row">

            <!-- +++++ 面包屑导航 +++++ -->
            <div class="col-lg-12">
                <ol class="my-breadcrumb">
                    <li><a href="/admin/blog">博客管理</a></li>
                    <li class="active">添加博客</li>
                </ol>
            </div>

            <div class="col-lg-12">
                <div class="my-well">
                    <div class="table-responsive">

                        <!-- +++++ 表单录入部分 +++++ -->
                        <form id="a" method="post" action="/admin/blog/addblog">
                            <table class="table">
                                <tr>
                                    <td>标题</td>
                                    <td>
                                        <div class="form-group"><input name="title" type="text" class="form-control"></div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>简介</td>
                                    <td>
                                        <div class="form-group"><input name="intro" type="text" class="form-control"></div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>正文</td>
                                    <td>
                                        <div id="editor"></div>
                                        <div>
                                            <input name="text" id="text" type="text" class="form-control" style="visibility: hidden">
                                        </div>
                                        <div class="form-group">
                                            <input name="html" id="html" type="hidden" class="form-control">
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>分类</td>
                                    <td>
                                        <div class="form-group">
                                            <select name="type" class= "form-control">
                                                <option value=""> 请选择一个分类</option >
                                                <?php foreach ($list as $v): ?>
                                                    <option value="<?=$v['id']?>"> <?=$v['name']?></option >
                                                <?php endforeach; ?>
                                            </select>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>操作</td>
                                    <td>
                                        <button type="submit" class="btn btn-danger" onclick="test()">提交</button>
                                        <button type="reset" class="btn btn-danger" >重置</button>
                                    </td>
                                </tr>
                            </table>
                        </form>

                    </div>
                </div>
            </div>

        </div><!-- /row -->
    </div> <!-- /container -->
</div><!-- /white -->

<!-- 注意， 只需要引用 JS，无需引用任何 CSS ！！！-->
<script type="text/javascript" src="/wangEditor/release/wangEditor.min.js"></script>
<script type="text/javascript">
    var E = window.wangEditor;
    var editor = new E('#editor');
    // 或者 var editor = new E( document.getElementById('#editor') )
    editor.create();

    //表单验证
    function test()
    {
        document.getElementById('text').value=editor.txt.text();
        document.getElementById('html').value=editor.txt.html();
        $("#a").validate({
            errorElement: "span",
            errorClass: "fa fa-exclamation-circle",
            rules: {
                title: "required",
                intro: "required",
                text: "required",
                type: "required"
            },
            messages: {
                title: " 请输入标题",
                intro: " 请输入简介",
                text: " 请输入正文",
                type: " 请选择一个类型"
            }
        });
    }
</script>